package com.xmkj.bearbiz.pk;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.ImageView;

import com.common.BearBean.BaseItem;
import com.common.widget.imageview.image.ImageLoaderUtils;
import com.common.widget.recyclerview.refresh.adapter.CommonAdapter;
import com.common.widget.recyclerview.refresh.adapter.ViewHolder;
import com.xmkj.bearbiz.R;

import java.util.List;

/**
 * Create by leo
 * 创建日期：2018/6/26
 * 描述：
 */

public class BaseListAdapter extends CommonAdapter<BaseItem> {
    public BaseListAdapter(Context context, List<BaseItem> data) {
        super(context, data);
    }

    @Override
    protected void convert(ViewHolder holder, final BaseItem item, int position) {
//        holder.setImageStr(R.id.iv_img,item.pic_url);
       ImageView  ivImg =  holder.getView(R.id.iv_img);
        ImageLoaderUtils.displayAllImg(ivImg,item.pic_url);
        holder.setText(R.id.tv_title,item.title);
        holder.setText(R.id.tv_content,item.content_abbreviate);
        holder.setText(R.id.tv_time,item.date);


        holder.getParentView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext,ContentDetailsActivity.class);
                intent.putExtra(ContentDetailsActivity.ACTIVITY_ID,item.activity_id+"");
                mContext.startActivity(intent);
            }
        });
    }

    @Override
    protected int getItemViewLayoutId(int position, BaseItem item) {
        return R.layout.item_base_list;
    }
}
